﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.
// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME      : FI.Net Application Framework
// COMPONENT ID     : ApplicationContext
// COMPONENT DESC   : Session based contextual data sharing.
//
// CREATED DATE/BY  : 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY :
// DATE/BY            SR#/CS/PM#/OTHERS      DESCRIPTION OF CHANGE
// ==================================================================================================
#endregion

using FI.Core.Configuration;
using System.Configuration;

namespace FI.Core.Localization.Configuration
{
    /// <summary>
    /// Represents Localization based <see cref="ConfigurationSection"/>.
    /// </summary>
    [ConfigurationSectionName(Constants.ConfigurationSections.Localization)]
    public class LocalizationSettings : ServiceLocatableSettings
    {
        #region Constants
        private const string convertToUtcProperty = "convertToUtc";
        #endregion

        #region Public Methods
        /// <summary>
        /// Needs the convert UTC.
        /// </summary>
        /// <returns></returns>
        public static bool NeedConvertUtc()
        {
            LocalizationSettings settings;
            if (ConfigManager.TryGetConfigurationSection<LocalizationSettings>(out settings))
            {
                return settings.ConvertToUtc;
            }
            return false;
        }

        #endregion

        #region Properties
        /// <summary>
        /// Gets or sets the time zone: Utc or Local.
        /// </summary>
        /// <value>The time zone.</value>
        [ConfigurationProperty(convertToUtcProperty, IsRequired = false, DefaultValue = false)]
        public bool ConvertToUtc
        {
            get { return (bool)(this[convertToUtcProperty]); }
            set { this[convertToUtcProperty] = value; }
        }
        #endregion
    }
}